package com.design.springboot.booksharing.bean;

import com.github.pagehelper.Page;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * REST 接口的请求结果的分页处理
 *
 * @author admin
 */
@Data
public class Pagination<T> implements Serializable {
    private static final long serialVersionUID = -8891629219067936790L;

    private Long total;

    private Integer pages;

    private Integer pageNum;

    private Integer pageSize;

    private List<T> list;

    public Pagination(Page<T> page) {
        this.total = page.getTotal();
        this.pages = page.getPages();
        this.pageNum = page.getPageNum();
        this.pageSize = page.getPageSize();
        this.list = page.getResult();
    }
}
